import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
//解决重复点击左侧菜单的报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


export const asyncRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    meta: {
      title: "灵溪AI",
    },
  },
  {
    path: '/',
    redirect: '/app',
    component: () => import('@/layout/index.vue'),
    meta: {
      title: "灵溪AI",
    },
    children: [
      {
        path: 'app',
        component: () => import('@/views/app/index.vue'),
        meta: {
          title: "灵溪AI",
        },
      },
      {
        path: 'conversation',
        meta: {
          title: "灵溪AI",
        },
        component: () => import('@/views/conversation/index.vue'),
        children: [
          {
            path: "chat",
            component: () => import('@/views/conversation/chat/index.vue'),
            meta: {
              title: "灵溪AI",
            },
          },
          {
            path: "wanxiang",
            component: () => import('@/views/conversation/wanxiang/index.vue'),
            meta: {
              title: "灵溪AI",
            },
          },
          {
            path: "mj",
            component: () => import('@/views/conversation/mj/index.vue'),
            meta: {
              title: "灵溪AI",
            },
          }
        ]
      },
      {
        path: 'faq',
        component: () => import('@/views/faq/index.vue'),
        meta: {
          title: "灵溪AI",
        },
      },
      {
        path: 'collection',
        redirect: '/collection-gpt',
        meta: {
          title: "灵溪AI",
        },
      },
      {
        path: 'collection-gpt',
        component: () => import('@/views/collection/gpt/index.vue'),
        meta: {
          title: "灵溪AI",
        },
      },
      {
        path: 'collection-mj',
        component: () => import('@/views/collection/gpt/index.vue'),
        meta: {
          title: "灵溪AI",
        },
      },
      {
        path: 'setting',
        redirect: '/setting/userInfo',
        component: () => import('@/views/setting/index.vue'),
        meta: {
          title: "灵溪AI",
        },
        children: [
          {
            path: 'userInfo',
            component: () => import('@/views/setting/userInfo/index.vue'),
            meta: {
              title: "个人资料",
            },
          },
          {
            path: 'password',
            component: () => import('@/views/setting/password/index.vue'),
            meta: {
              title: "修改密码",
            },
          },
          {
            path: 'history',
            name: 'history',
            component: () => import('@/views/setting/history/index.vue'),
            meta: {
              title: "历史记录",
            },
          },
          {
            path: 'model',
            component: () => import('@/views/setting/model/index.vue'),
            meta: {
              title: "灵溪AI",
            },
          }
        ]
      },
      {
        path: 'admin',
        redirect: '/admin/user',
        component: () => import('@/views/admin/index.vue'),
        meta: {
          title: "灵溪AI",
        },
        children: [
          {
            path: 'user',
            component: () => import('@/views/admin/user/index.vue'),
            meta: {
              title: "用户管理",
            },
          },
        ]
      },
    ]
  },
]


const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes: asyncRoutes
})

export default router
